package com.ucampus.controller;

import com.ucampus.entity.oS_foods;
import com.ucampus.service.oS_foodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 功能：
 * 作者： 启明星_Polaris
 * 日期：2025/1/6 下午3:39
 **/

@RestController
@RequestMapping("/foods")
public class oS_foodsController {
    @Autowired
    private oS_foodsService foodsService;

    // 分页查询食品信息
    @GetMapping("/page")
    public ResponseEntity<List<oS_foods>> getFoodsByPage(
            @RequestParam("page") int page,
            @RequestParam(value = "size", defaultValue = "7") int size) {
        List<oS_foods> foods = foodsService.getFoodsByPage(page, size);
        return foods != null && !foods.isEmpty() ? ResponseEntity.ok(foods) : ResponseEntity.notFound().build();
    }
}
